<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>fullscreen</title>
    <style>
        body:fullscreen {
            background-color: #2396ef;
        }
        body,html {
            height: 100%;
            margin: 0;
            padding: 0;
        }
        body {
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: 5em;
            color:#2396ef;
        }
    </style>
</head>
<body>
    随意点击页面即可进入/退出全屏
    <script>
        const fullscreen = (mode = true,el = 'body') => mode ? document.querySelector(el).requestFullscreen() : document.exitFullscreen();
        const el = document.querySelector('body');
        let mode = false;
        el.addEventListener("click",() => {
            mode = !mode;
            fullscreen(mode)
        })
    </script>
</body>
</html>